<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>使用配置 | liran</title>
    <meta name="generator" content="VuePress 1.8.2">
    <link rel="icon" href="/img/favicon.ico">
    <meta name="description" content="liran note">
    <meta name="keywords" content="我是content">
    <meta name="theme-color" content="#11a8cd">
    <link rel="preload" href="/assets/css/0.styles.0a02024d.css" as="style"><link rel="preload" href="/assets/js/app.3c810432.js" as="script"><link rel="preload" href="/assets/js/2.86379151.js" as="script"><link rel="preload" href="/assets/js/10.52a7ec83.js" as="script"><link rel="preload" href="/assets/js/3.9eb29365.js" as="script"><link rel="prefetch" href="/assets/js/11.ef9c9dd5.js"><link rel="prefetch" href="/assets/js/12.4e438e6d.js"><link rel="prefetch" href="/assets/js/13.962a4298.js"><link rel="prefetch" href="/assets/js/14.cc384da1.js"><link rel="prefetch" href="/assets/js/15.bb801760.js"><link rel="prefetch" href="/assets/js/16.1641b9c9.js"><link rel="prefetch" href="/assets/js/17.0d495285.js"><link rel="prefetch" href="/assets/js/18.8c0ed479.js"><link rel="prefetch" href="/assets/js/19.7294d692.js"><link rel="prefetch" href="/assets/js/20.fd8383bc.js"><link rel="prefetch" href="/assets/js/4.27f548a3.js"><link rel="prefetch" href="/assets/js/5.735f4bf2.js"><link rel="prefetch" href="/assets/js/6.6918e2a3.js"><link rel="prefetch" href="/assets/js/7.bdd56c44.js"><link rel="prefetch" href="/assets/js/8.a026c9e8.js"><link rel="prefetch" href="/assets/js/9.75871346.js">
    <link rel="stylesheet" href="/assets/css/0.styles.0a02024d.css">
  </head>
  <body class="theme-mode-light">
    <div id="app" data-server-rendered="true"><div class="theme-container sidebar-open have-rightmenu"><header class="navbar blur"><div title="目录" class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/" class="home-link router-link-active"><img src="/img/logo.svg" alt="liran" class="logo"> <span class="site-name can-hide">liran</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/" class="nav-link">首页</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="指南" class="dropdown-title"><a href="/pages/24112f/" class="link-title">指南</a> <span class="title" style="display:none;">指南</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/pages/24112f/" class="nav-link">快速入门</a></li><li class="dropdown-item"><!----> <a href="/pages/779a6e/" class="nav-link">核心功能</a></li><li class="dropdown-item"><!----> <a href="/pages/6b03c5/" class="nav-link">扩展</a></li><li class="dropdown-item"><!----> <a href="/pages/2976a3/" class="nav-link">插件</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="配置" class="dropdown-title"><a href="/pages/56bac0/" aria-current="page" class="link-title router-link-exact-active router-link-active">配置</a> <span class="title" style="display:none;">配置</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/pages/56bac0/" aria-current="page" class="nav-link router-link-exact-active router-link-active">使用配置</a></li><li class="dropdown-item"><!----> <a href="/pages/981406/" class="nav-link">代码生成器配置新</a></li><li class="dropdown-item"><!----> <a href="/pages/061573/" class="nav-link">代码生成器配置旧</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="liran" class="dropdown-title"><a href="/04.test" class="link-title">liran</a> <span class="title" style="display:none;">liran</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/pages/a7b3a6/" class="nav-link">基础</a></li><li class="dropdown-item"><!----> <a href="/pages/4b3960/" class="nav-link">提升</a></li></ul></div></div><div class="nav-item"><a href="/archives/" class="nav-link">归档</a></div> <a href="https://github.com/baomidou/mybatis-plus" target="_blank" rel="noopener noreferrer" class="repo-link">
    GitHub
    <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav></div></header> <div class="sidebar-mask"></div> <aside class="sidebar" style="display:none;"><!----> <nav class="nav-links"><div class="nav-item"><a href="/" class="nav-link">首页</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="指南" class="dropdown-title"><a href="/pages/24112f/" class="link-title">指南</a> <span class="title" style="display:none;">指南</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/pages/24112f/" class="nav-link">快速入门</a></li><li class="dropdown-item"><!----> <a href="/pages/779a6e/" class="nav-link">核心功能</a></li><li class="dropdown-item"><!----> <a href="/pages/6b03c5/" class="nav-link">扩展</a></li><li class="dropdown-item"><!----> <a href="/pages/2976a3/" class="nav-link">插件</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="配置" class="dropdown-title"><a href="/pages/56bac0/" aria-current="page" class="link-title router-link-exact-active router-link-active">配置</a> <span class="title" style="display:none;">配置</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/pages/56bac0/" aria-current="page" class="nav-link router-link-exact-active router-link-active">使用配置</a></li><li class="dropdown-item"><!----> <a href="/pages/981406/" class="nav-link">代码生成器配置新</a></li><li class="dropdown-item"><!----> <a href="/pages/061573/" class="nav-link">代码生成器配置旧</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="liran" class="dropdown-title"><a href="/04.test" class="link-title">liran</a> <span class="title" style="display:none;">liran</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/pages/a7b3a6/" class="nav-link">基础</a></li><li class="dropdown-item"><!----> <a href="/pages/4b3960/" class="nav-link">提升</a></li></ul></div></div><div class="nav-item"><a href="/archives/" class="nav-link">归档</a></div> <a href="https://github.com/baomidou/mybatis-plus" target="_blank" rel="noopener noreferrer" class="repo-link">
    GitHub
    <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav>  <ul class="sidebar-links"><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>使用配置</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/pages/56bac0/" aria-current="page" class="active sidebar-link">使用配置</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/pages/56bac0/#基本配置" class="sidebar-link">基本配置</a></li><li class="sidebar-sub-header"><a href="/pages/56bac0/#使用方式" class="sidebar-link">使用方式</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/pages/56bac0/#configlocation" class="sidebar-link">configLocation</a></li><li class="sidebar-sub-header"><a href="/pages/56bac0/#mapperlocations" class="sidebar-link">mapperLocations</a></li><li class="sidebar-sub-header"><a href="/pages/56bac0/#typealiasespackage" class="sidebar-link">typeAliasesPackage</a></li><li class="sidebar-sub-header"><a href="/pages/56bac0/#typealiasessupertype" class="sidebar-link">typeAliasesSuperType</a></li><li class="sidebar-sub-header"><a href="/pages/56bac0/#typehandlerspackage" class="sidebar-link">typeHandlersPackage</a></li><li class="sidebar-sub-header"><a href="/pages/56bac0/#typeenumspackage" class="sidebar-link">typeEnumsPackage</a></li><li class="sidebar-sub-header"><a href="/pages/56bac0/#checkconfiglocation" class="sidebar-link">checkConfigLocation</a></li><li class="sidebar-sub-header"><a href="/pages/56bac0/#executortype" class="sidebar-link">executorType</a></li><li class="sidebar-sub-header"><a href="/pages/56bac0/#configurationproperties" class="sidebar-link">configurationProperties</a></li><li class="sidebar-sub-header"><a href="/pages/56bac0/#configuration" class="sidebar-link">configuration</a></li></ul></li><li class="sidebar-sub-header"><a href="/pages/56bac0/#configuration-2" class="sidebar-link">Configuration</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/pages/56bac0/#mapunderscoretocamelcase" class="sidebar-link">mapUnderscoreToCamelCase</a></li><li class="sidebar-sub-header"><a href="/pages/56bac0/#defaultenumtypehandler" class="sidebar-link">defaultEnumTypeHandler</a></li><li class="sidebar-sub-header"><a href="/pages/56bac0/#aggressivelazyloading" class="sidebar-link">aggressiveLazyLoading</a></li><li class="sidebar-sub-header"><a href="/pages/56bac0/#automappingbehavior" class="sidebar-link">autoMappingBehavior</a></li><li class="sidebar-sub-header"><a href="/pages/56bac0/#automappingunknowncolumnbehavior" class="sidebar-link">autoMappingUnknownColumnBehavior</a></li><li class="sidebar-sub-header"><a href="/pages/56bac0/#localcachescope" class="sidebar-link">localCacheScope</a></li><li class="sidebar-sub-header"><a href="/pages/56bac0/#cacheenabled" class="sidebar-link">cacheEnabled</a></li><li class="sidebar-sub-header"><a href="/pages/56bac0/#callsettersonnulls" class="sidebar-link">callSettersOnNulls</a></li><li class="sidebar-sub-header"><a href="/pages/56bac0/#configurationfactory" class="sidebar-link">configurationFactory</a></li></ul></li><li class="sidebar-sub-header"><a href="/pages/56bac0/#globalconfig-2" class="sidebar-link">GlobalConfig</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/pages/56bac0/#banner" class="sidebar-link">banner</a></li><li class="sidebar-sub-header"><a href="/pages/56bac0/#enablesqlrunner" class="sidebar-link">enableSqlRunner</a></li><li class="sidebar-sub-header"><a href="/pages/56bac0/#sqlinjector" class="sidebar-link">sqlInjector</a></li><li class="sidebar-sub-header"><a href="/pages/56bac0/#supermapperclass" class="sidebar-link">superMapperClass</a></li><li class="sidebar-sub-header"><a href="/pages/56bac0/#metaobjecthandler" class="sidebar-link">metaObjectHandler</a></li><li class="sidebar-sub-header"><a href="/pages/56bac0/#identifiergenerator-since-3-3-0" class="sidebar-link">identifierGenerator(since 3.3.0)</a></li><li class="sidebar-sub-header"><a href="/pages/56bac0/#dbconfig" class="sidebar-link">dbConfig</a></li></ul></li><li class="sidebar-sub-header"><a href="/pages/56bac0/#dbconfig-2" class="sidebar-link">DbConfig</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/pages/56bac0/#idtype" class="sidebar-link">idType</a></li><li class="sidebar-sub-header"><a href="/pages/56bac0/#tableprefix" class="sidebar-link">tablePrefix</a></li><li class="sidebar-sub-header"><a href="/pages/56bac0/#schema" class="sidebar-link">schema</a></li><li class="sidebar-sub-header"><a href="/pages/56bac0/#columnformat" class="sidebar-link">columnFormat</a></li><li class="sidebar-sub-header"><a href="/pages/56bac0/#propertyformat-since-3-3-0" class="sidebar-link">propertyFormat(since 3.3.0)</a></li><li class="sidebar-sub-header"><a href="/pages/56bac0/#tableunderline" class="sidebar-link">tableUnderline</a></li><li class="sidebar-sub-header"><a href="/pages/56bac0/#capitalmode" class="sidebar-link">capitalMode</a></li><li class="sidebar-sub-header"><a href="/pages/56bac0/#keygenerator" class="sidebar-link">keyGenerator</a></li><li class="sidebar-sub-header"><a href="/pages/56bac0/#logicdeletefield" class="sidebar-link">logicDeleteField</a></li><li class="sidebar-sub-header"><a href="/pages/56bac0/#logicdeletevalue" class="sidebar-link">logicDeleteValue</a></li><li class="sidebar-sub-header"><a href="/pages/56bac0/#logicnotdeletevalue" class="sidebar-link">logicNotDeleteValue</a></li><li class="sidebar-sub-header"><a href="/pages/56bac0/#insertstrategy" class="sidebar-link">insertStrategy</a></li><li class="sidebar-sub-header"><a href="/pages/56bac0/#updatestrategy" class="sidebar-link">updateStrategy</a></li><li class="sidebar-sub-header"><a href="/pages/56bac0/#selectstrategy" class="sidebar-link">selectStrategy</a></li></ul></li></ul></li></ul></section></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>代码生成器配置</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/pages/981406/" class="sidebar-link">代码生成器配置新</a></li><li><a href="/pages/061573/" class="sidebar-link">代码生成器配置旧</a></li></ul></section></li></ul> </aside> <div><main class="page"><div class="theme-vdoing-wrapper "><!----> <!----> <div class="content-wrapper"><div class="right-menu-wrapper"><div class="right-menu-margin"><div class="right-menu-content"></div></div></div> <h1><img src="">
          使用配置
        </h1>  <div class="theme-vdoing-content content__default"><p>本文讲解了<code>MyBatis-Plus</code>在使用过程中的配置选项，其中，部分配置继承自<code>MyBatis</code>原生所支持的配置</p> <h2 id="基本配置"><a href="#基本配置" class="header-anchor">#</a> 基本配置</h2> <p>本部分配置包含了大部分用户的常用配置，其中一部分为 MyBatis 原生所支持的配置</p> <h2 id="使用方式"><a href="#使用方式" class="header-anchor">#</a> 使用方式</h2> <p>Spring Boot:</p> <div class="language-yaml line-numbers-mode"><pre class="language-yaml"><code><span class="token key atrule">mybatis-plus</span><span class="token punctuation">:</span>
  <span class="token punctuation">...</span><span class="token punctuation">...</span>
  <span class="token key atrule">configuration</span><span class="token punctuation">:</span>
    <span class="token punctuation">...</span><span class="token punctuation">...</span>
  <span class="token key atrule">global-config</span><span class="token punctuation">:</span>
    <span class="token punctuation">...</span><span class="token punctuation">...</span>
    <span class="token key atrule">db-config</span><span class="token punctuation">:</span>
      <span class="token punctuation">...</span><span class="token punctuation">...</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br></div></div><p>Spring MVC：</p> <div class="language-xml line-numbers-mode"><pre class="language-xml"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>bean</span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>sqlSessionFactory<span class="token punctuation">&quot;</span></span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>property</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>configuration<span class="token punctuation">&quot;</span></span> <span class="token attr-name">ref</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>configuration<span class="token punctuation">&quot;</span></span><span class="token punctuation">/&gt;</span></span> <span class="token comment">&lt;!--  非必须  --&gt;</span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>property</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>globalConfig<span class="token punctuation">&quot;</span></span> <span class="token attr-name">ref</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>globalConfig<span class="token punctuation">&quot;</span></span><span class="token punctuation">/&gt;</span></span> <span class="token comment">&lt;!--  非必须  --&gt;</span>
    ......
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>bean</span><span class="token punctuation">&gt;</span></span>

<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>bean</span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>configuration<span class="token punctuation">&quot;</span></span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>com.baomidou.mybatisplus.core.MybatisConfiguration<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
    ......
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>bean</span><span class="token punctuation">&gt;</span></span>

<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>bean</span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>globalConfig<span class="token punctuation">&quot;</span></span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>com.baomidou.mybatisplus.core.config.GlobalConfig<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>property</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>dbConfig<span class="token punctuation">&quot;</span></span> <span class="token attr-name">ref</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>dbConfig<span class="token punctuation">&quot;</span></span><span class="token punctuation">/&gt;</span></span> <span class="token comment">&lt;!--  非必须  --&gt;</span>
    ......
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>bean</span><span class="token punctuation">&gt;</span></span>

<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>bean</span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>dbConfig<span class="token punctuation">&quot;</span></span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>com.baomidou.mybatisplus.core.config.GlobalConfig.DbConfig<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
    ......
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>bean</span><span class="token punctuation">&gt;</span></span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br></div></div><h3 id="configlocation"><a href="#configlocation" class="header-anchor">#</a> configLocation</h3> <ul><li>类型：<code>String</code></li> <li>默认值：<code>null</code></li></ul> <p>MyBatis 配置文件位置，如果您有单独的 MyBatis 配置，请将其路径配置到 <code>configLocation</code> 中.MyBatis Configuration 的具体内容请参考<a href="https://www.mybatis.org/mybatis-3/zh/configuration.html" target="_blank" rel="noopener noreferrer">MyBatis 官方文档<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <h3 id="mapperlocations"><a href="#mapperlocations" class="header-anchor">#</a> mapperLocations</h3> <ul><li>类型：<code>String[]</code></li> <li>默认值：<code>[&quot;classpath*:/mapper/**/*.xml&quot;]</code></li></ul> <p>MyBatis Mapper 所对应的 XML 文件位置，如果您在 Mapper 中有自定义方法(XML 中有自定义实现)，需要进行该配置，告诉 Mapper 所对应的 XML 文件位置</p> <div class="custom-block warning"><p class="custom-block-title">注意</p> <p>Maven 多模块项目的扫描路径需以 <code>classpath*:</code> 开头 （即加载多个 jar 包下的 XML 文件）</p></div> <h3 id="typealiasespackage"><a href="#typealiasespackage" class="header-anchor">#</a> typeAliasesPackage</h3> <ul><li>类型：<code>String</code></li> <li>默认值：<code>null</code></li></ul> <p>MyBaits 别名包扫描路径，通过该属性可以给包中的类注册别名，注册后在 Mapper 对应的 XML 文件中可以直接使用类名，而不用使用全限定的类名(即 XML 中调用的时候不用包含包名)</p> <h3 id="typealiasessupertype"><a href="#typealiasessupertype" class="header-anchor">#</a> typeAliasesSuperType</h3> <ul><li>类型：<code>Class&lt;?&gt;</code></li> <li>默认值：<code>null</code></li></ul> <p>该配置请和 <a href="#typealiasespackage">typeAliasesPackage</a> 一起使用，如果配置了该属性，则仅仅会扫描路径下以该类作为父类的域对象</p> <h3 id="typehandlerspackage"><a href="#typehandlerspackage" class="header-anchor">#</a> typeHandlersPackage</h3> <ul><li>类型：<code>String</code></li> <li>默认值：<code>null</code></li></ul> <p>TypeHandler 扫描路径，如果配置了该属性，SqlSessionFactoryBean 会把该包下面的类注册为对应的 TypeHandler</p> <div class="custom-block tip"><p class="custom-block-title">提示</p> <p>TypeHandler 通常用于自定义类型转换。</p></div> <h3 id="typeenumspackage"><a href="#typeenumspackage" class="header-anchor">#</a> typeEnumsPackage</h3> <ul><li>类型：<code>String</code></li> <li>默认值：<code>null</code></li></ul> <p>枚举类 扫描路径，如果配置了该属性，会将路径下的枚举类进行注入，让实体类字段能够简单快捷的使用枚举属性</p> <h3 id="checkconfiglocation"><a href="#checkconfiglocation" class="header-anchor">#</a> checkConfigLocation <span class="badge error" style="vertical-align:top;" data-v-d5affa18>Spring Boot Only</span></h3> <ul><li>类型：<code>boolean</code></li> <li>默认值：<code>false</code></li></ul> <p>启动时是否检查 MyBatis XML 文件的存在，默认不检查</p> <h3 id="executortype"><a href="#executortype" class="header-anchor">#</a> executorType <span class="badge error" style="vertical-align:top;" data-v-d5affa18>Spring Boot Only</span></h3> <ul><li>类型：<code>ExecutorType</code></li> <li>默认值：<code>simple</code></li></ul> <p>通过该属性可指定 MyBatis 的执行器，MyBatis 的执行器总共有三种：</p> <ul><li>ExecutorType.SIMPLE：该执行器类型不做特殊的事情，为每个语句的执行创建一个新的预处理语句（PreparedStatement）</li> <li>ExecutorType.REUSE：该执行器类型会复用预处理语句（PreparedStatement）</li> <li>ExecutorType.BATCH：该执行器类型会批量执行所有的更新语句</li></ul> <h3 id="configurationproperties"><a href="#configurationproperties" class="header-anchor">#</a> configurationProperties</h3> <ul><li>类型：<code>Properties</code></li> <li>默认值：<code>null</code></li></ul> <p>指定外部化 MyBatis Properties 配置，通过该配置可以抽离配置，实现不同环境的配置部署</p> <h3 id="configuration"><a href="#configuration" class="header-anchor">#</a> configuration</h3> <ul><li>类型：<code>Configuration</code></li> <li>默认值：<code>null</code></li></ul> <p>原生 MyBatis 所支持的配置，具体请查看 <a href="#Configuration">Configuration</a></p> <h4 id="globalconfig"><a href="#globalconfig" class="header-anchor">#</a> globalConfig</h4> <ul><li>类型：<code>com.baomidou.mybatisplus.core.config.GlobalConfig</code></li> <li>默认值：<code>GlobalConfig::new</code></li></ul> <p>MyBatis-Plus 全局策略配置，具体请查看 <a href="#GlobalConfig">GlobalConfig</a></p> <h2 id="configuration-2"><a href="#configuration-2" class="header-anchor">#</a> Configuration</h2> <p>本部分（Configuration）的配置大都为 MyBatis 原生支持的配置，这意味着您可以通过 MyBatis XML 配置文件的形式进行配置。</p> <h3 id="mapunderscoretocamelcase"><a href="#mapunderscoretocamelcase" class="header-anchor">#</a> mapUnderscoreToCamelCase</h3> <ul><li>类型：<code>boolean</code></li> <li>默认值：<code>true</code></li></ul> <p>是否开启自动驼峰命名规则（camel case）映射，即从经典数据库列名 A_COLUMN（下划线命名） 到经典 Java 属性名 aColumn（驼峰命名） 的类似映射。</p> <div class="custom-block tip"><p class="custom-block-title">注意</p> <p>此属性在 MyBatis 中原默认值为 false，在 MyBatis-Plus 中，此属性也将用于生成最终的 SQL 的 select body</p> <p>如果您的数据库命名符合规则无需使用 <code>@TableField</code> 注解指定数据库字段名</p></div> <h3 id="defaultenumtypehandler"><a href="#defaultenumtypehandler" class="header-anchor">#</a> defaultEnumTypeHandler</h3> <ul><li>类型：<code>Class&lt;? extends TypeHandler</code></li> <li>默认值：<code>org.apache.ibatis.type.EnumTypeHandler</code></li></ul> <p>默认枚举处理类,如果配置了该属性,枚举将统一使用指定处理器进行处理</p> <div class="custom-block tip"><p class="custom-block-title">提示</p> <ul><li>org.apache.ibatis.type.EnumTypeHandler : 存储枚举的名称</li> <li>org.apache.ibatis.type.EnumOrdinalTypeHandler : 存储枚举的索引</li> <li>com.baomidou.mybatisplus.extension.handlers.MybatisEnumTypeHandler : 枚举类需要实现 IEnum 接口或字段标记@EnumValue 注解.(3.1.2 以下版本为 EnumTypeHandler)</li> <li><s>com.baomidou.mybatisplus.extension.handlers.EnumAnnotationTypeHandler: 枚举类字段需要标记@EnumValue 注解</s></li></ul></div> <h3 id="aggressivelazyloading"><a href="#aggressivelazyloading" class="header-anchor">#</a> aggressiveLazyLoading</h3> <ul><li>类型：<code>boolean</code></li> <li>默认值：<code>true</code></li></ul> <p>当设置为 true 的时候，懒加载的对象可能被任何懒属性全部加载，否则，每个属性都按需加载。需要和 <a href="">lazyLoadingEnabled</a> 一起使用。</p> <h3 id="automappingbehavior"><a href="#automappingbehavior" class="header-anchor">#</a> autoMappingBehavior</h3> <ul><li>类型：<code>AutoMappingBehavior</code></li> <li>默认值：<code>partial</code></li></ul> <p>MyBatis 自动映射策略，通过该配置可指定 MyBatis 是否并且如何来自动映射数据表字段与对象的属性，总共有 3 种可选值：</p> <ul><li>AutoMappingBehavior.NONE：不启用自动映射</li> <li>AutoMappingBehavior.PARTIAL：只对非嵌套的 resultMap 进行自动映射</li> <li>AutoMappingBehavior.FULL：对所有的 resultMap 都进行自动映射</li></ul> <h3 id="automappingunknowncolumnbehavior"><a href="#automappingunknowncolumnbehavior" class="header-anchor">#</a> autoMappingUnknownColumnBehavior</h3> <ul><li>类型：<code>AutoMappingUnknownColumnBehavior</code></li> <li>默认值：<code>NONE</code></li></ul> <p>MyBatis 自动映射时未知列或未知属性处理策略，通过该配置可指定 MyBatis 在自动映射过程中遇到未知列或者未知属性时如何处理，总共有 3 种可选值：</p> <ul><li>AutoMappingUnknownColumnBehavior.NONE：不做任何处理 (默认值)</li> <li>AutoMappingUnknownColumnBehavior.WARNING：以日志的形式打印相关警告信息</li> <li>AutoMappingUnknownColumnBehavior.FAILING：当作映射失败处理，并抛出异常和详细信息</li></ul> <h3 id="localcachescope"><a href="#localcachescope" class="header-anchor">#</a> localCacheScope</h3> <ul><li>类型：<code>String</code></li> <li>默认值：<code>SESSION</code></li></ul> <p>Mybatis 一级缓存，默认为 SESSION。</p> <ul><li>SESSION session 级别缓存，同一个 session 相同查询语句不会再次查询数据库</li> <li>STATEMENT 关闭一级缓存</li></ul> <p>单服务架构中（有且仅有只有一个程序提供相同服务），一级缓存开启不会影响业务，只会提高性能。
微服务架构中需要关闭一级缓存，原因：Service1 先查询数据，若之后 Service2 修改了数据，之后 Service1 又再次以同样的查询条件查询数据，因走缓存会出现查处的数据不是最新数据</p> <h3 id="cacheenabled"><a href="#cacheenabled" class="header-anchor">#</a> cacheEnabled</h3> <ul><li>类型：<code>boolean</code></li> <li>默认值：<code>true</code></li></ul> <p>开启 Mybatis 二级缓存，默认为 true。</p> <h3 id="callsettersonnulls"><a href="#callsettersonnulls" class="header-anchor">#</a> callSettersOnNulls</h3> <ul><li>类型：<code>boolean</code></li> <li>默认值：<code>false</code></li></ul> <p>指定当结果集中值为 null 的时候是否调用映射对象的 Setter（Map 对象时为 put）方法，通常运用于有 Map.keySet() 依赖或 null 值初始化的情况。</p> <p>通俗的讲，即 MyBatis 在使用 resultMap 来映射查询结果中的列，如果查询结果中包含空值的列，则 MyBatis 在映射的时候，不会映射这个字段，这就导致在调用到该字段的时候由于没有映射，取不到而报空指针异常。</p> <p>当您遇到类似的情况，请针对该属性进行相关配置以解决以上问题。</p> <div class="custom-block warning"><p class="custom-block-title">注意</p> <p>基本类型（int、boolean 等）是不能设置成 null 的。</p></div> <h3 id="configurationfactory"><a href="#configurationfactory" class="header-anchor">#</a> configurationFactory</h3> <ul><li>类型：<code>Class&lt;?&gt;</code></li> <li>默认值：<code>null</code></li></ul> <p>指定一个提供 Configuration 实例的工厂类。该工厂生产的实例将用来加载已经被反序列化对象的懒加载属性值，其必须包含一个签名方法<code>static Configuration getConfiguration()</code>。（从 3.2.3 版本开始）</p> <h2 id="globalconfig-2"><a href="#globalconfig-2" class="header-anchor">#</a> GlobalConfig</h2> <h3 id="banner"><a href="#banner" class="header-anchor">#</a> banner</h3> <ul><li>类型：<code>boolean</code></li> <li>默认值：<code>true</code></li></ul> <p>是否控制台 print mybatis-plus 的 LOGO</p> <h3 id="enablesqlrunner"><a href="#enablesqlrunner" class="header-anchor">#</a> enableSqlRunner</h3> <ul><li>类型：<code>boolean</code></li> <li>默认值：<code>false</code></li></ul> <p>是否初始化 SqlRunner(com.baomidou.mybatisplus.extension.toolkit.SqlRunner)</p> <h3 id="sqlinjector"><a href="#sqlinjector" class="header-anchor">#</a> sqlInjector</h3> <ul><li>类型：<code>com.baomidou.mybatisplus.core.injector.ISqlInjector</code></li> <li>默认值：<code>com.baomidou.mybatisplus.core.injector.DefaultSqlInjector</code></li></ul> <p>SQL 注入器(starter 下支持<code>@bean</code>注入)</p> <h3 id="supermapperclass"><a href="#supermapperclass" class="header-anchor">#</a> superMapperClass</h3> <ul><li>类型：<code>Class</code></li> <li>默认值：<code>com.baomidou.mybatisplus.core.mapper.Mapper.class</code></li></ul> <p>通用 Mapper 父类(影响 sqlInjector,只有这个的子类的 mapper 才会注入 sqlInjector 内的 method)</p> <h3 id="metaobjecthandler"><a href="#metaobjecthandler" class="header-anchor">#</a> metaObjectHandler</h3> <ul><li>类型：<code>com.baomidou.mybatisplus.core.handlers.MetaObjectHandler</code></li> <li>默认值：<code>null</code></li></ul> <p>元对象字段填充控制器(starter 下支持<code>@bean</code>注入)</p> <h3 id="identifiergenerator-since-3-3-0"><a href="#identifiergenerator-since-3-3-0" class="header-anchor">#</a> identifierGenerator(since 3.3.0)</h3> <ul><li>类型：<code>com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator</code></li> <li>默认值：<code>com.baomidou.mybatisplus.core.incrementer.DefaultIdentifierGenerator</code></li></ul> <p>Id 生成器(starter 下支持<code>@bean</code>注入)</p> <h3 id="dbconfig"><a href="#dbconfig" class="header-anchor">#</a> dbConfig</h3> <ul><li>类型：<code>com.baomidou.mybatisplus.core.config.GlobalConfig$DbConfig</code></li> <li>默认值：<code>null</code></li></ul> <p>MyBatis-Plus 全局策略中的 DB 策略配置，具体请查看 <a href="#DbConfig">DbConfig</a></p> <h2 id="dbconfig-2"><a href="#dbconfig-2" class="header-anchor">#</a> DbConfig</h2> <h3 id="idtype"><a href="#idtype" class="header-anchor">#</a> idType</h3> <ul><li>类型：<code>com.baomidou.mybatisplus.annotation.IdType</code></li> <li>默认值：<code>ASSIGN_ID</code></li></ul> <p>全局默认主键类型</p> <h3 id="tableprefix"><a href="#tableprefix" class="header-anchor">#</a> tablePrefix</h3> <ul><li>类型：<code>String</code></li> <li>默认值：<code>null</code></li></ul> <p>表名前缀</p> <h3 id="schema"><a href="#schema" class="header-anchor">#</a> schema</h3> <ul><li>类型：<code>String</code></li> <li>默认值：<code>null</code></li></ul> <p>schema</p> <h3 id="columnformat"><a href="#columnformat" class="header-anchor">#</a> columnFormat</h3> <ul><li>类型：<code>String</code></li> <li>默认值：<code>null</code></li></ul> <p>字段 format,例: <code>%s</code>,(对主键无效)</p> <h3 id="propertyformat-since-3-3-0"><a href="#propertyformat-since-3-3-0" class="header-anchor">#</a> propertyFormat(since 3.3.0)</h3> <ul><li>类型：<code>String</code></li> <li>默认值：<code>null</code></li></ul> <p>entity 的字段(property)的 format,只有在 column as property 这种情况下生效例: <code>%s</code>,(对主键无效)</p> <h3 id="tableunderline"><a href="#tableunderline" class="header-anchor">#</a> tableUnderline</h3> <ul><li>类型：<code>boolean</code></li> <li>默认值：<code>true</code></li></ul> <p>表名是否使用驼峰转下划线命名,只对表名生效</p> <h3 id="capitalmode"><a href="#capitalmode" class="header-anchor">#</a> capitalMode</h3> <ul><li>类型：<code>boolean</code></li> <li>默认值：<code>false</code></li></ul> <p>大写命名,对表名和字段名均生效</p> <h3 id="keygenerator"><a href="#keygenerator" class="header-anchor">#</a> keyGenerator</h3> <ul><li>类型：<code>com.baomidou.mybatisplus.core.incrementer.IKeyGenerator</code></li> <li>默认值：<code>null</code></li></ul> <p>表主键生成器(starter 下支持<code>@bean</code>注入)</p> <h3 id="logicdeletefield"><a href="#logicdeletefield" class="header-anchor">#</a> logicDeleteField</h3> <ul><li>类型：<code>String</code></li> <li>默认值：<code>null</code></li></ul> <p>全局的 entity 的逻辑删除字段属性名,(<a href="/guide/logic-delete.html">逻辑删除</a>下有效)</p> <h3 id="logicdeletevalue"><a href="#logicdeletevalue" class="header-anchor">#</a> logicDeleteValue</h3> <ul><li>类型：<code>String</code></li> <li>默认值：<code>1</code></li></ul> <p>逻辑已删除值,(<a href="/guide/logic-delete.html">逻辑删除</a>下有效)</p> <h3 id="logicnotdeletevalue"><a href="#logicnotdeletevalue" class="header-anchor">#</a> logicNotDeleteValue</h3> <ul><li>类型：<code>String</code></li> <li>默认值：<code>0</code></li></ul> <p>逻辑未删除值,(<a href="/guide/logic-delete.html">逻辑删除</a>下有效)</p> <h3 id="insertstrategy"><a href="#insertstrategy" class="header-anchor">#</a> insertStrategy</h3> <ul><li>类型：<code>com.baomidou.mybatisplus.annotation.FieldStrategy</code></li> <li>默认值：<code>NOT_NULL</code></li></ul> <p>字段验证策略之 insert,在 insert 的时候的字段验证策略</p> <h3 id="updatestrategy"><a href="#updatestrategy" class="header-anchor">#</a> updateStrategy</h3> <ul><li>类型：<code>com.baomidou.mybatisplus.annotation.FieldStrategy</code></li> <li>默认值：<code>NOT_NULL</code></li></ul> <p>字段验证策略之 update,在 update 的时候的字段验证策略</p> <h3 id="selectstrategy"><a href="#selectstrategy" class="header-anchor">#</a> selectStrategy</h3> <ul><li>类型：<code>com.baomidou.mybatisplus.annotation.FieldStrategy</code></li> <li>默认值：<code>NOT_NULL</code></li></ul> <p>字段验证策略之 select,在 select 的时候的字段验证策略既 wrapper 根据内部 entity 生成的 where 条件</p></div></div>  <div class="page-edit"><div class="edit-link"><a href="https://github.com/baomidou/mybatis-plus/edit/master/docs/02.配置/01.使用配置/01.使用配置.md" target="_blank" rel="noopener noreferrer">编辑</a> <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></div> <!----> <!----></div> <div class="page-nav-wapper"><div class="page-nav-centre-wrap"><!----> <a href="/pages/981406/" class="page-nav-centre page-nav-centre-next"><div class="tooltip">代码生成器配置新</div></a></div> <div class="page-nav"><p class="inner"><!----> <span class="next"><a href="/pages/981406/">代码生成器配置新</a>→
      </span></p></div></div></div> <!----></main></div> <div class="footer"><div class="icons"><a href="https://github.com/baomidou" title="GitHub" target="_blank" class="iconfont icon-github"></a><a href="https://gitee.com/baomidou" title="Gitee" target="_blank" class="iconfont icon-gitee"></a><a href="mailto:koyangslash@gmail.com" title="发邮件" target="_blank" class="iconfont icon-youjian"></a></div> 
  Theme by
  <a href="https://github.com/xugaoyi/vuepress-theme-vdoing" target="_blank" title="本站主题">Vdoing</a> 
    | Copyright © 2016-2021
    <span><a href="http://baomidou.com" target="_blank" style="font-weight:bold">Team Baomidou</a> | Sponsored by <a href="https://www.jetbrains.com" target="_blank" style="font-weight:bold">JetBrains</a> | <a href="http://beian.miit.gov.cn/" target=_blank>渝ICP备2021000141号</a><p>友情链接：<a href="http://aizuda.com" target="_blank" style="font-weight:bold">AiZuDa</a> | <a href="https://dyang.top/" target="_blank" style="font-weight:bold">D.Yang</a> | <a href="https://blog.nancheung.com/" target="_blank" style="font-weight:bold">NanCheung</a></p></span></div> <div class="buttons"><div title="返回顶部" class="button blur go-to-top iconfont icon-fanhuidingbu" style="display:none;"></div> <div title="去评论" class="button blur go-to-comment iconfont icon-pinglun" style="display:none;"></div> <div title="主题模式" class="button blur theme-mode-but iconfont icon-zhuti"><ul class="select-box" style="display:none;"><li class="iconfont icon-zidong">
          跟随系统
        </li><li class="iconfont icon-rijianmoshi">
          浅色模式
        </li><li class="iconfont icon-yejianmoshi">
          深色模式
        </li><li class="iconfont icon-yuedu">
          阅读模式
        </li></ul></div></div> <!----> <!----> <!----></div><div class="global-ui"></div></div>
    <script src="/assets/js/app.3c810432.js" defer></script><script src="/assets/js/2.86379151.js" defer></script><script src="/assets/js/10.52a7ec83.js" defer></script><script src="/assets/js/3.9eb29365.js" defer></script>
  </body>
</html>